<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML>
<html style='height:100%'>
<head>
<base href="<%=basePath%>">

<title>信用管理</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<link rel="stylesheet" href="css/vivo.css">
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="js/bootstrap2/css/bootstrap.min.css">
<link rel="stylesheet" href="js/bootstrap2/css/bootstrap-table.css">
<link rel="stylesheet" href="css/common.css">

<script src="js/jquery-1.11.1.js"></script>
<script src="js/bootstrap2/js/bootstrap.min.js"></script>
<script src="js/bootstrap2/js/bootstrap-table.js"></script>
<script src="js/bootstrap2/js/bootstrap-table-zh-CN.js"></script>
<script type="text/javascript" src="js/layui-v2.1.5/layui/layui.all.js"></script>
<script src="js/sharefunction.js"></script>
<script type="text/javascript" src="js/form.js"></script>
<script type="text/javascript">
	//修改字段标记记录变量
	var marks="原数据";
	$(document).ready(function() {
		initCreditMsg();
		$(function() {
			mySubmit("creditForm", initCredit, successCredit);
		});
		toolTip();
		
	});
	var ci;
	function initCreditMsg() {
		var data = ${requestScope.list};
		if (data.length>0) {
			var html = "";
			for(var i=0; i < data.length;i++){
				var creditType = data[i].creditType;
				var content = data[i].content;
				var id = data[i].id;
				if(data[i].creditType=="司法纠纷"){
					var t = $("#sifa table");
					appendHtml(creditType,content,id,t);
				}else if(data[i].creditType=="矛盾投诉"){
					var t = $("#maodun table");
					appendHtml(creditType,content,id,t);
				}else if(data[i].creditType=="交易信息"){
					var t = $("#jiaoyi table");
					appendHtml(creditType,content,id,t);
				}else{
					var t = $("#other table");
					appendHtml(creditType,content,id,t);
				}
			}
		}
		$("#creditForm").find("input,textarea").attr("readonly", true);
		$("#creditForm").find(".addbtn").hide();
		$("#creditForm").find(".icon-fullscreen").hide(); 
		$("#creditForm textarea[name='remark']").attr("readonly",false);
	}
	
	function appendHtml(creditType,content,id,t){
		html = "<tr><td width=\"73\"align=\"center\">记录</td><td><input name=\"creditType\"type=\"hidden\" value=\""+creditType+"\"/><input id=\"entityId_ids\" name=\"id\"type=\"hidden\" value=\""+id+"\"/><textarea name=\"content\"rows=\"3\"cols=\"70\"style=\"width:70%;\">"+content+"</textarea>"
		+"<a data-id=\""+id+"\" href=\"javascript:void(0)\"onclick=\"delTrCredit(this)\"><i class=\"icon-fullscreen\"></i></a>";
		 var a=${requestScope.contrastMap};
		 
		//如果是查看审批页面过来的  则不执行该方法体
		 if(null != a[id]&&${ requestScope.notPassExamine}){
		  	if( "" == a[id].content){
			 	html += "<span class=\"toolTip mark-msg\"data-tip=\"空\">"+marks+"</span>";
			 }else if("" != a[id].content){
			 	html += "<span class=\"toolTip mark-msg\"data-tip=\""+a[id].content+"\">"+marks+"</span>";
			 }
		  }
		 
		html += "</td></tr>"
		$(t).append(html);
	}
	var spFlag;
	//creditSubmit操作字段，0：拒绝；1：同意
	function creditSubmit(val) {
		spFlag = val;
		$("#creditForm").submit();
	}
	function initCredit() {
		var mli = layer.load(2);
		var remark = $("#creditForm [name='remark']").val();
		var exDataId = $("#exDataId").val();//序列化id
		var pendingId=$("#pendingId").val();//待审批表单id
		if (remark == "") {
			layer.msg("审批说明不能为空");
			$("#creditForm [name='remark']").focus();
			layer.close(mli);
			return null;
		} else {
			return {
				exDataId:exDataId,
				pendingId:pendingId,
				spflag:spFlag,
				remark:remark
			};
		}
	}
	//成功回调
	function successCredit(responseText) {
		layer.close(ci);
		if (responseText.success) {
			layer.alert("保存成功！", {
				offset:'20%',
				shade:[0.1,'#fff']
			}, function() {
				parent.location.reload();
				layer.close(ci);
			});
		} else {
			layer.alert('保存失败！');
		}
	}
</script>
</head>
<body style='height:100%'>
	<form class="cmxform" id="creditForm" method="post"
		action="customer/credit/doPendCredit" onsubmit="return false;">
		<div>
			<div class="panel panel-default">
				<div class="panel-body">
					<!-- 司法纠纷 -->
					<div class="style_box3" id="sifa">
						<table cellpadding="10" cellspacing="5" class="mytable" id="lawnArea">
							<tr style="border-bottom:1px solid gray">
								<td width="73"  class="td-right"><span class="style_btn">司法纠纷</span>
								</td>
								<td><a class="btn btn-danger radius addbtn"
									 onclick="addTrCredit(this)" style="display: none"> 添加</a></td>
							</tr>
						</table>
					</div>
					<!-- 矛盾投诉-->
					<div class="style_box3" id="maodun">
						<table cellpadding="10" cellspacing="5" class="mytable" id="herbal" >
							<tr style="border-bottom:1px solid gray">
								<td width="73"><span class="style_btn">矛盾投诉</span>
								</td>
								<td><a class="btn btn-danger radius addbtn"
									 onclick="addTrCredit(this)" style="display: none"> 添加</a></td>
							</tr>
							
						</table>
					</div>
					<!-- 交易信息 -->
					<div class="style_box3" id="jiaoyi">
						<table cellpadding="10" cellspacing="5" class="mytable" id="woody">
							<tr style="border-bottom:1px solid gray">
								<td width="73"><span class="style_btn">交易信息</span>
								</td>
								<td><!-- <a class="btn btn-danger radius addbtn"
									 onclick="addTrCredit(this)"> 添加</a> --></td>
							</tr>
						</table>
					</div>
					<!-- 其他信用 -->
					<div class="style_box3" id="other">
						<table cellpadding="10" cellspacing="5" class="mytable" id="trees">
							<tr style="border-bottom:1px solid gray">
								<td width="73"><span class="style_btn">其他信用</span>
								</td>
								<td colspan="5"><a class="btn btn-danger radius addbtn"
									 onclick="addTrCredit(this)" style="display: none"> 添加</a></td>
							</tr>
						</table>
					</div>
				</div>
			</div>
			<c:if test="${ requestScope.notPassExamine }">
				<!-- 修改时添加变更说明 -->
				<div style="margin:10px;"  id="remark">
					审批说明：<textarea rows="3" name="remark" style="width:70%"></textarea><span style="color:red;">*</span>
				</div>
				<div style="width:100%;text-align:center; padding-top:20px">
					<!-- 保存状态 -->
					<button class="btn btn-danger radius"
						onClick="creditSubmit(1);" type="button">同意</button>
					<button class="btn btn-default radius"
						onClick="creditSubmit(0);" type="button">拒绝</button>
				</div>
			</c:if>
			<input type="hidden" name="pendingId" id="pendingId" value="${pendingId }" />
			<input type="hidden" name="exDataId" id="exDataId" value="${exDataId }" />
		</div>
	</form>

	<script type="text/javascript">
		function resetCredit(){
			$("creditFormnput,textarea").val("");
			//$("#creditForm").find("select").val("司法纠纷").trigger("change");
		}
		
		function addTrCredit(obj) {
			var creditType = $(obj).parent().prev().text().trim();
			var html = "<tr><td width=\"73\"align=\"center\">记录</td><td><input name=\"creditType\"type=\"hidden\" value=\""+creditType+"\"/><input id=\"entityId_ids\" name=\"id\"type=\"hidden\"/><textarea name=\"content\"rows=\"3\"cols=\"70\"style=\"width:70%;\"></textarea>"
					+"<a href=\"javascript:void(0)\"onclick=\"delTrCredit(this)\"><i class=\"icon-fullscreen\"></i></a></td></tr>";
			$(obj).parent().parent().parent().append(html);
		}
		
	</script>
</body>